package validations;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class FileValidation {
		private static InputStream isf1;
		private static InputStream isf2;

		public static boolean checkDuplicate(String file, String file2) {
			
			File f1 = new File(file);  
		    File f2 = new File(file2);  
		    byte[] f1_buf = new byte[1048576];  
		    byte[] f2_buf = new byte[1048576];  
		    int len;  
		    if (f1.length() == f2.length()) {  
		        try {  
		            isf1 = new FileInputStream(f1);  
		            isf2 = new FileInputStream(f2);  
		            try {  
		                while (isf1.read(f1_buf) >= 0)
		                {  
		                    len=isf2.read(f2_buf);  
		                    for (int j = 0; j < len; j++)
		                    {  
		                        if (f1_buf[j] != f2_buf[j])
		                        {  
		                            return false; // tamanho igual e conteudo diferente
		                        }  
		                    }  
		                } 
		                
		                isf1.close();
			            isf2.close();  
		             
		            } catch (IOException e) {  
		            } 
		            
		        
		            
		        } catch (FileNotFoundException e) {  
		        }  
		    } else {  
		        return false; // tamanho e conteudo diferente  
		   }  
		    return true; // arquivos iguais  
	    }
		
}

        
        
        
      